Depth of field refers to a range behind and in front of a focus point that appear sharp. Depth of field can decide whether to blur a background to highlight a photographed object or display a sharp background. For a two-dimensional image, a depth of field effect may be simulated by performing some processing, so as to achieve the objective of highlighting an object on an image.
An existing depth of field effect simulation solution usually adopts a pinhole imaging model based filtering solution. In the solution, a depth value z of each pixel is calculated according to a standard pinhole camera model; a circle of confusion (a circle of confusion: on an imaging plane in front of, or behind, or near a focal plane, light rays from a point light source do not focus on a point, so that the image becomes a circle of confusion) for each sampling point is calculated according to the depth value z, aperture, focus length, and the like; a final value of each pixel is determined by a weighted average of all circles of confusion covering the pixel thereof. In the solution, in a simulation calculation process based on a pinhole imaging model or a lens model, the focus length and aperture parameters of a camera needs to be know in advance; however, in actual application, it is difficult to obtain camera photographing parameters of any two-dimensional image with accuracy, so that application scenarios of the solution are restricted, and the depth of field effect simulation cannot be performed on any two-dimensional image. In addition, because the calculation process of the solution needs to depend on parameters of a camera, the calculation process is complex and the calculation amount is huge.
In addition, a solution of blurring a background layer by layer around a human face area is adopted. The solution is blurring the background layer by layer around the human face area based on a human face recognition technology. The disadvantages thereof lie in that the human face recognition technology only applies to portrait scenarios; and in this solution, depth of field is simulated by adopting a manner of performing gradient blurring around a center, and parameters for blurring processing are fixed, so that the blurring processing manner cannot be adjusted accordingly depending on different target areas on the an image and a single depth of field effect is appeared; therefore, the impact of pixel depth information on the blurring degree thereof cannot be effectively reflected. However, the depth of field effect photographed by an actual camera varies depending on focus length, aperture, and object distance, which results a feature of one-way or two-way gradient blurring. A target area is an area where a highlighted object is located.